<template>
  <div>
    <div class="main clearfix" id="jhTable">
      <el-form :inline="true" :model="form" class="demo-form-inline" ref="empform">
        <div class="wrap">
          <el-form-item label="企业名称" prop="companyname">
            <el-input v-model="form.companyname" placeholder="输入企业名称" clearable></el-input>
          </el-form-item>
          <el-form-item label="岗位名称" prop="positionname">
            <el-input v-model="form.positionname" placeholder="输入岗位名称" clearable></el-input>
          </el-form-item>
          <el-form-item label="求职者名称" prop="employeename">
            <el-input v-model="form.employeename" placeholder="输入求职者名称" clearable></el-input>
          </el-form-item>
          <el-form-item label="求职者电话" prop="telnum">
            <el-input v-model="form.telnum" placeholder="输入求职者电话" clearable></el-input>
          </el-form-item>
          <el-form-item label="扫码时间" prop="time">
            <el-date-picker
              v-model="form.starttime"
              type="date"
              placeholder="选择日期"
              format="yyyy-MM-dd"
              value-format="yyyy-MM-dd"
              style="width:140px"
              @change="changeTime"
            ></el-date-picker>~
            <el-date-picker
              v-model="form.endtime"
              type="date"
              placeholder="选择日期"
              format="yyyy-MM-dd"
              value-format="yyyy-MM-dd"
              style="width:140px"
              @change="changeTime"
            ></el-date-picker>
          </el-form-item>
        </div>
        <div class="wrap">
          <el-form-item>
            <!-- <el-button style="width: 120px" @click="reset">重置</el-button> -->
            <el-button style="width: 120px" type="primary" @click="search">查询</el-button>
          </el-form-item>
        </div>
      </el-form>
      <el-table stripe border :data="list" size="small" style="width:100%">
        <el-table-column prop="companyname" label="企业名称" align="center" width="200px"></el-table-column>
        <el-table-column prop="positionname" label="岗位名称" align="center"></el-table-column>
        <el-table-column prop="employeename" label="求职者名称" align="center"></el-table-column>
        <el-table-column prop="telnum" label="求职者电话" align="center"></el-table-column>
        <el-table-column prop="inserttime" label="扫码时间" align="center"></el-table-column>
      </el-table>
      <div class="block" style="padding-top: 20px;">
        <el-pagination
          background
          :current-page="form.pagenum"
          :page-size="form.pagesize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
          :page-sizes="[10, 20, 30, 50, 100]"
          @current-change="handleCurrentChange"
          @size-change="handleSizeChange"
        ></el-pagination>
      </div>
    </div>
  </div>
</template>


<script>
export default {
  name: "employment",
  components: {
    tab: () => import("../../../component/tab/index.vue"),
    cityCascader: () => import("../../../component/cityCascader/index.vue"),
    check: () => import("../../socical/socialCheck/check.vue")
  },
  data() {
    return {
      options: [
        {
          table: "3001",
          tablename: "企业招聘人员管理",
          buttonlist: [
            { button: "300101", buttonname: "会员拉黑" },
            { button: "300104", buttonname: "会员导出" },
            { button: "300102", buttonname: "会员提醒" },
            { button: "300103", buttonname: "上报(拉黑)" }
          ],
          val: "0"
        },
        {
          table: "3002",
          tablename: "打卡记录",
          buttonlist: [
            { button: "300203", buttonname: "黑名单导出" },
            { button: "300201", buttonname: "会员还原" },
            { button: "300202", buttonname: "还原上报" }
          ],
          val: "1"
        }
      ],
      active_type: "0",
      form: {
        starttime: "",
        endtime: "",
        companyname: "", //企业名称
        positionname: "", //岗位名称
        employeename: "", //求职者名称
        telnum: "", //求职者电话
        pagenum: 1,
        pagesize: 10
      },
      level: "0",
      total: 0,
      list: [],
      list2: [], //打卡记录table
      typeList: [],
      sizeList: [],
      checkFlag: false,
      info: ""
    };
  },
  mounted() {
    this.getTableData();
  },
  methods: {
    handleClick(item) {
      this.active_type = item.val;
    },
    // 获取列表数据
    getTableData() {
      this.$axios
        .post("/app/v1/platform/company/scanCodeCommitList", this.form)
        .then(res => {
			console.log(res);
          if (res.data.code === 1) {
            let result = res.data.data;
            this.list = result.list;
            this.total = Number(result.totalnum);
          } else {
            this.$message({
              message: res.data.message,
              type: "error"
            });
          }
        });
    },
    // 搜索
    search() {
      this.form.pagenum = 1;
      this.getTableData();
    },
    // 重置
    reset() {
      this.$refs["empform"].resetFields();
      this.form.pagenum = 1;
    },
    checkInfo(r) {
      this.checkFlag = true;
      this.info = r;
    },
    // 分页
    handleCurrentChange(val) {
      this.form.pagenum = val;
      this.getTableData();
    },
    handleSizeChange(val) {
      this.form.pagenum = 1;
      this.form.pagesize = val;
      this.getTableData();
    },
    changeTime() {
      console.log("form", this.form.starttime);
      console.log("form", this.form.endtime);
      let d1 = new Date(this.form.starttime);
      let d2 = new Date(this.form.endtime);
      if (d2 && d1 > d2) {
        this.form.endtime = "";
        this.$message.warning("开始时间不能大于结束时间");
      }
    }
  }
};
</script>

<style scoped src="./index.css"></style>